package com.twq.patternmatch.pattern

/**
 * Created by tangweiqun on 2017/11/22.
 * option与模式匹配
 */
object PatternMatchOption {
  def main(args: Array[String]): Unit = {
    val capitals =
      Map("France" -> "Paris", "Japan" -> "Tokyo")

    show(capitals get "Japan") //res25: String = Tokyo
    show(capitals get "France") //res26: String = Paris
    show(capitals get "North Pole") //res27: String = ?
  }

  //Some 和None 是Option这种数据结构的两个子集
  def show(x: Option[String]) = x match {
    case Some(s) => s
    case None => "?"
  }
}
